// 接收来自后台的消息
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
	
});

// 主动发送消息给后台background
// 要演示此功能，请打开控制台主动执行sendMessageToBackground()
function sendMessageToBackground(options) {
	chrome.runtime.sendMessage(options, function(response) {
		// console.log(response)
	});
}

// 注入js
function injectJS(path, type, cb){
	const jspath = chrome.extension.getURL(path);
	const js = document.createElement('script');
	js.src = jspath;
	// js.async='async';
	js.type = type || 'text/javascript';
	document.body.appendChild(js);
	if (cb instanceof Function) js.onload=function(){cb();}
}
injectJS('static/js/vendors/jquery.slim.min.js', '', function(){
	injectJS('views/pdd.tools.js', 'module', () => console.log('tools loaded'));
	console.log('jquery loaded')
})
injectJS('static/js/vendors/utils.js')